package com.sq.partner.manager;
import java.util.Map;

import com.sq.partner.manager.util.JMXUtils;


/**
 * JMX获取计数服务，用于获取交易流量等
 * 
 * @author Panyu
 * 
 */
public class CounterManager {
	
	
	/** 服务名称，如"福建交易流量" */
	private String name;
	/** JMX的serviceURL */
	private String serviceURL;
	/** JMX的objectName */
	private String objectName;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getServiceURL() {
		return serviceURL;
	}

	public void setServiceURL(String serviceURL) {
		this.serviceURL = serviceURL;
	}

	public String getObjectName() {
		return objectName;
	}

	public void setObjectName(String objectName) {
		this.objectName = objectName;
	}

	/**
	 * 获取计数
	 */
	public Map<Integer,Integer> getCountMap() throws  Exception {
			return (Map<Integer,Integer>)JMXUtils.invoke(serviceURL, objectName,"getCountMap", new Object[0], new String[0]);
	}

	/**
	 * 获取计数时间（单位分钟），即统计多少分钟内的交易流量
	 */
	public int getCountPeriod() throws  Exception{
			return (Integer) JMXUtils.invoke(serviceURL, objectName,"getCountPeriod", new Object[0], new String[0]);
	}

	/**
	 * 获取上次更新时间
	 */
	public long getLastUpdateTime() throws  Exception{
			return (Long) JMXUtils.invoke(serviceURL, objectName,"getLastUpdateTime", new Object[0], new String[0]);
	}

}
